// 书写会议室管理的接口
import request from '@/utils/request'
import {
  RoomInformationResponseData,
  RoomInformation,
  ResponseData,
  searchRoom,
  AllRooms,
} from './type'
//接口地址
enum API {
  // 获取已有会议室信息（分页查询）
  ROOMDATA_URL = 'room/roomPage/',
  // 添加会议室
  ADDROOMDATA_URL = 'room/addRoom/',
  // 修改会议室
  UPDATEROOMDATA_URL = 'room/updateRoom/',
  // 删除会议室
  DELETEROOMDATA_URL = 'room/deleteRoomOne/',
  // 查询会议室接口/
  SEARCHROOMDATEA_URL = 'room/roomPageData',
  // 获取会议室列表
  GETROOMLIST_URL = 'room/getRoomList',
}

// 获取会议室列表
export const reqRoomData = () => request.get<any, AllRooms>(API.GETROOMLIST_URL)

// 获取已有会议室信息（分页查询）
export const reqSearchRoomData = (params: searchRoom) =>
  request.get<any, RoomInformationResponseData>(API.SEARCHROOMDATEA_URL, {
    params: params,
  })
// 添加与修改会议室
export const reqAddOrUpdateRoomData = (data: RoomInformation) => {
  // 修改会议室数据
  if (data.id) {
    return request.put<any, ResponseData>(API.UPDATEROOMDATA_URL, data)
  } else {
    return request.post<any, ResponseData>(API.ADDROOMDATA_URL, data)
  }
}

export const reqDeleteRoomData = (id: number) =>
  request.delete<any, ResponseData>(API.DELETEROOMDATA_URL + `${id}`)
